package top.zlcode.friend.controller.exam;

import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.zlcode.common.core.controller.BaseController;
import top.zlcode.common.core.domain.R;
import top.zlcode.common.core.domain.TableDataInfo;
import top.zlcode.friend.domain.exam.dto.ExamQueryDTO;
import top.zlcode.friend.domain.exam.dto.ExamRankDTO;
import top.zlcode.friend.domain.exam.vo.ExamDetailVO;
import top.zlcode.friend.service.exam.IExamService;

@RestController
@RequestMapping("/exam")
public class ExamController extends BaseController {

    @Autowired
    private IExamService examService;

    @PostMapping("/semiLogin/list")
    public TableDataInfo queryPage(@RequestBody ExamQueryDTO examQueryDTO) {
        return examService.queryPage(examQueryDTO);
    }

    /**
     * 获取竞赛中的第一个题目
     * @param examId
     * @return
     */
    @GetMapping("/getFirstQuestion")
    public R<String> getFirstQuestion(Long examId) {
        return R.ok(examService.getFirstQuestion(examId));
    }

    /**
     * 竞赛的前一个题目
     * @param examId
     * @param questionId
     * @return
     */
    @GetMapping("/preQuestion")
    public R<String> preQuestion(Long examId, Long questionId) {
        return R.ok(examService.preQuestion(examId, questionId));
    }

    /**
     * 竞赛的下一个题目
     * @param examId
     * @param questionId
     * @return
     */
    @GetMapping("/nextQuestion")
    public R<String> nextQuestion(Long examId, Long questionId) {
        return R.ok(examService.nextQuestion(examId, questionId));
    }

    @GetMapping("/detail")
    @Operation(summary = "获取竞赛里面的题目信息", description = "根据 examId 获取这个竞赛下的题目")
    public R<ExamDetailVO> detail(Long examId) {
        return R.ok(examService.detail(examId));
    }

    /**
     * 竞赛排名
     * @param examRankDTO
     * @return
     */
    @GetMapping("/rank/list")
    public TableDataInfo rankList(ExamRankDTO examRankDTO) {
        return examService.rankList(examRankDTO);
    }

}
